import request from "@/utils/alova/alova.ts";
import type {
  getAllSingerType,
  loginType,
  responseType,
  userType,
} from "@/types/apiTypes/userTypes.ts";

// 登录
export const login = (data: loginType) => {
  return request.Post<responseType>("/consumer/login", data);
};

// 查询所有歌手
export const getAllSinger = (params: getAllSingerType) => {
  return request.Get<responseType>("/singer/allSinger", { params });
};
// 根据歌手查询歌曲
export const getSongsBySinger = (userId: number, singerId: number) => {
  return request.Get<responseType>(
    `collect/isCollect?userId=${userId}&singerId=${singerId}`
  );
};
// 收藏歌曲
export const collectSong = (userId: number, songId: number) => {
  return request.Post<responseType>(
    `collect/toCollected?userId=${userId}&songId=${songId}`
  );
};
// 歌单
export const getAllSongList = () => {
  return request.Get<responseType>("/songList/allSongList");
};
// 歌单获取歌曲
export const getSongListSongs = (userId: number, songListId: number) => {
  return request.Get<responseType>(
    `/collect/isCollected?userId=${userId}&songListId=${songListId}`
  );
};
// 修改用户信息
export const updateUser = (data: userType) => {
  return request.Post<responseType>("/consumer/update", data);
};

// 获取歌曲详情

export const getSongById = (id: number) => {
  return request.Get<responseType>(`/song/queryById?id=${id}`);
};
